package de.szut.util;

import java.util.Arrays;

/**
 * Represents a console message
 * @author Marc Huisinga
 *
 */
public final class ConsoleMessage implements Message, Immutable {
	private final String[] lines;
	
	/**
	 * @param lines - lines of this message
	 */
	public ConsoleMessage(String... lines) {
		this.lines = lines;
	}

	@Override
	public void output() {
		for (String line : lines) {
			System.out.println(line);
		}
	}

	@Override
	public String[] getLines() {
		return lines;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("ConsoleMessage [lines=");
		builder.append(Arrays.toString(lines));
		builder.append("]");
		return builder.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Arrays.hashCode(lines);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof ConsoleMessage)) {
			return false;
		}
		ConsoleMessage other = (ConsoleMessage) obj;
		if (!Arrays.equals(lines, other.lines)) {
			return false;
		}
		return true;
	}
	
	
}
